
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.data.time.Day;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author ronaldoats
 */
public class Logic {

    private float[] Espesor;
    private float[] TInterna;
    private float[] TExterna;
    private int Fecha;

    public void setFecha(int Fecha) {
        this.Fecha = Fecha;
    }

    public void setEspesor(float[] SE) {
        this.Espesor = SE;
    }

    public void setTInterna(float[] STI) {
        this.TInterna = STI;
    }

    public void setTExterna(float[] STE) {
        this.TExterna = STE;
    }

    private TimeSeries LineaInterna() {
        TimeSeries TS1_LI = new TimeSeries("-", Day.class);
        return TS1_LI;
    }

    private TimeSeries V(float[] v, String Title) {
        TimeSeries T1 = new TimeSeries(Title, Day.class);
        for (int i = 1; i <= v.length; i++) {
            T1.add(new Day(1, (i + 1), Fecha + i), v[i - 1]);
        }
        return T1;
    }

    public void GenerarImagenInterna() throws IOException {
        TimeSeriesCollection dataset = new TimeSeriesCollection();
        dataset.addSeries(this.V(Espesor, "Espesor"));
        dataset.addSeries(this.V(TInterna, "Temperatura Interna Kelvin"));
        dataset.addSeries(this.V(TExterna, "Temperatura Externa"));

        dataset.addSeries(LineaInterna());

        JFreeChart chart = ChartFactory.createTimeSeriesChart(
                "",
                "",
                "",
                dataset,
                true,
                true,
                true);
        ChartUtilities.saveChartAsJPEG(new File("chartFE.jpg"), chart, 1440, 900);
        ChartFrame frame = new ChartFrame("First", chart);
        frame.pack();
        frame.setVisible(true);
        int x = 0;
    }
}
